#import "DDNaviBar.h"
CGFloat const JTWNaviBarHeight = 44;
@interface DDNaviBar ()
@property (nonatomic, strong) UILabel *titleLBL;
@end
@implementation DDNaviBar
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.titleLBL.hidden = NO;
    }
    return self;
}
- (UILabel *)titleLBL
{
    if (!_titleLBL)
    {
       _titleLBL = [[UILabel alloc] init];
//        _titleLBL.backgroundColor = ORANGE_COLOR;
        _titleLBL.textColor = [UIColor blackColor];
        _titleLBL.font = FONT(UIFontWeightBold, 18);
        _titleLBL.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLBL];
        _titleLBL.c_edges.equal(UIEdgeInsetsZero);
    }
    return _titleLBL;
}
- (UIButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [[UIButton alloc] init];
        [_backBtn setBackgroundImage:[@"back" yjd_image] forState:UIControlStateNormal];
        [_backBtn addTarget:self action:@selector(yjd_actionForBackButton) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_backBtn];
        _backBtn.c_left.equal(self);
        _backBtn.c_top.equal(self);
        _backBtn.c_bottom.equal(self);
        _backBtn.c_width.equal(JTWNaviBarHeight);
    }
    return _backBtn;
}
- (UIButton *)cancelBtn
{
    if (!_cancelBtn)
    {
        _cancelBtn = [[UIButton alloc] init];
        [_cancelBtn setBackgroundImage:[@"cancel" yjd_image] forState:UIControlStateNormal];
        [_cancelBtn addTarget:self action:@selector(yjd_actionForCancelButton) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_cancelBtn];
        _cancelBtn.c_right.equal(self);
        _cancelBtn.c_top.equal(self);
        _cancelBtn.c_bottom.equal(self);
        _cancelBtn.c_width.equal(JTWNaviBarHeight);
    }
    return _cancelBtn;
}
- (UIColor *)backgroundColor
{
    return self.titleLBL.backgroundColor;
}
- (void)setTitle:(NSString *)title
{
    if (_title != title)
    {
        _title = title;
        self.titleLBL.text = _title;
    }
}
- (void)yjd_actionForBackButton
{
        if (self.delegate && [self.delegate respondsToSelector:@selector(shouldBackToPreviousViewController)])
        {
            [self.delegate shouldBackToPreviousViewController];
        }
}
- (void)yjd_actionForCancelButton
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(shouldCancelCurrentViewController)])
    {
        [self.delegate shouldCancelCurrentViewController];
    }
}

- (void)sp_getLoginState {
    NSLog(@"Get Info Failed");
}
@end
